import java.util.*;
public class lk1930 {
    public static void main(String[] args) {
        String s="tlpjzdmtwderpkpmgoyrcxttiheassztncqvnfjeyxxp";
        System.out.println(countPalindromicSubsequence(s));
    }
    public static int countPalindromicSubsequence(String s) {
        int n=s.length();
        if(n<=2){
            return 0;
        }
        int count =0,c1=0,c2=0;
        char a[]=s.toCharArray();
        int co[]=new int[26];
        for(int i=0;i<n;i++){
            co[(int)a[i]-97]++;
        }
        int end=0;
        for(int i=0;i<26;i++){
            if(co[i]>1){
                HashSet sites = new HashSet<>();
                c1=s.indexOf((char)i+97);
                c2=s.lastIndexOf((char)i+97);
                for(int j=c1+1;j<c2;j++){
                    sites.add(a[j]);
                }
                end+=sites.size();
            }
        }
        return end;

    }
}
